package nl.boelen.game.graphics;

import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import nl.boelen.game.Game;

public class SpriteSheet {
    public String path;
    public int width;
    public int height;
    public int[] pixels;
    private static int totalTilesWidth;
    public int totalTilesHeight;

    public SpriteSheet(String path) {
        BufferedImage image = null;
        try {
            image = ImageIO.read(SpriteSheet.class.getResourceAsStream(path));
        } catch (IOException e) {
            e.printStackTrace();
        }

        if (image == null) {
            return;
        }

        this.path = path;
        this.width = image.getWidth();
        this.height = image.getHeight();
        this.totalTilesWidth = this.width / Game.TILE_SIZE;
        this.totalTilesHeight = this.height / Game.TILE_SIZE;

        pixels = image.getRGB(0, 0, width, height, null, 0, width);
    }

    public static int getTotalTilesWidth() {
        return totalTilesWidth;
    }
}
